package com.ctshk.sapp.hotel.controller;


import com.ctshk.common.dto.Result;
import com.ctshk.common.model.TokenUser;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.hotel.dto.HotelInitializationSettingsDTO;
import com.ctshk.rpc.hotel.req.HotelInitializationSettingsReq;
import com.ctshk.rpc.hotel.service.IHotelInitializationSettingsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 * 酒店api初始化设置表 前端控制器
 * </p>
 *
 * @author yinhuan
 * @since 2021-03-03
 */
@RestController
@Api(value = "API初始化设置", tags = "API初始化设置")
@RequestMapping("/hotel/initialization/settings")
public class HotelInitializationSettingsController extends BaseController {
    @DubboReference
    private IHotelInitializationSettingsService hotelInitializationSettingsService;

    @ApiOperation(value = "酒店api初始化设置", notes = "酒店api初始化设置")
    @PostMapping(value = "/save")
    public Result saveSettingInfo(@RequestBody @Valid HotelInitializationSettingsReq hotelInitializationSettingsReq) {
        TokenUser user = getCurrentUser(getRequest());
        return hotelInitializationSettingsService.saveSettingInfo(hotelInitializationSettingsReq,user);
    }

    @ApiOperation(value = "查询酒店初始化默认API详情", notes = "查询酒店初始化默认API详情")
    @GetMapping(value = "/detail")
    public Result<HotelInitializationSettingsDTO> queryDetail(@RequestParam(value = "supplierId", required = false) String supplierId) {
        return Result.success(hotelInitializationSettingsService.queryDetail(supplierId));
    }
}
